package com.v2future.sjt.collegecheckingattendance.home.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.v2future.sjt.collegecheckingattendance.R;
import com.v2future.sjt.collegecheckingattendance.fruit.bean.ConditionTypeBean;
import com.v2future.sjt.collegecheckingattendance.utils.WidgetUtil;

/**
 * 单文本适配器
 * @author shijianting
 * @time 2016/5/25 11:11
 */
public class OneLineTextAdapter extends BaseAdapter{
    String[] dataList;
    Context mContext;
    ConditionTypeBean conditionTypeBean;//成长类型

    public OneLineTextAdapter(String[] dataList, Context mContext) {
        this.dataList = dataList;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return dataList.length;
    }

    @Override
    public Object getItem(int position) {
        return dataList[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public ConditionTypeBean getConditionTypeBean() {
        return conditionTypeBean;
    }

    public void setConditionTypeBean(ConditionTypeBean conditionTypeBean) {
        this.conditionTypeBean = conditionTypeBean;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        String str = dataList[position];
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.listitem_one_text, null);
            holder = new ViewHolder();
            holder.tv = (TextView) convertView.findViewById(R.id.tv);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        WidgetUtil.setText(holder.tv, str);
        return convertView;
    }

    public class ViewHolder {
        TextView tv;

    }
}
